package com.vfa.vocaburay;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

//import com.vfa.data.ConnectivityManager;
//import com.vfa.data.NetworkInfo;

public class TestNetworkConnection {
	
	 /**
	  * Check network connection status
	  * @param context
	  * @return boolean
	  */
	 public static boolean getNetworkStatusNoDialog(Context context){  
	  
	  boolean result = false;
	  if(null == context){
	   android.os.Process.killProcess(android.os.Process.myUid());
	   return false;
	  }
	  
	  ConnectivityManager connectionManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
	  NetworkInfo wifi = connectionManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
	  NetworkInfo mobile = connectionManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
	  if(wifi.isAvailable()){
	   if(wifi.isConnected()){
	    wifi = null;
	    result = true;
	   }else{
	    if(mobile.isConnected()){ 
	     mobile = null;
	     result = true;
	    }
	   }
	  }else if(mobile.isAvailable()){
	   if(mobile.isConnected()){ 
	    mobile = null;
	    result = true;
	   } 
	  }
	  
	  return result;
	 }

}
